# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks
_realname=kdiff3
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.12.3
pkgrel=1
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url="https://apps.kde.org/kdiff3/"
msys2_repository_url="https://invent.kde.org/sdk/kdiff3/"
msys2_references=(
  'archlinux: kdiff3'
)
license=('spdx:GPL-2.0-or-later')
groups=("${MINGW_PACKAGE_PREFIX}-kde-applications"
        "${MINGW_PACKAGE_PREFIX}-kdesdk")
depends=("${MINGW_PACKAGE_PREFIX}-icu"
         "${MINGW_PACKAGE_PREFIX}-kconfig"
         "${MINGW_PACKAGE_PREFIX}-kcoreaddons"
         "${MINGW_PACKAGE_PREFIX}-kconfigwidgets"
         "${MINGW_PACKAGE_PREFIX}-kcrash"
         "${MINGW_PACKAGE_PREFIX}-ki18n"
         "${MINGW_PACKAGE_PREFIX}-kio"
         "${MINGW_PACKAGE_PREFIX}-kwidgetsaddons"
         "${MINGW_PACKAGE_PREFIX}-kxmlgui"
         "${MINGW_PACKAGE_PREFIX}-qt6-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-icoutils"
             "${MINGW_PACKAGE_PREFIX}-kdoctools"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://download.kde.org/stable/${_realname}/${_realname}-${pkgver}.tar.xz"{,.sig})
sha256sums=('e22654c457881799808305529c6b596c0c9dc38b5a2ecc142ec76d46f6873f4c'
            'SKIP')
validpgpkeys=(EE56D710885D36FB1E4D21F3F442B36D614B06BC) # Michael Reeves <reeves.87@gmail.com>

build() {
  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    _extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  _kde_build_env
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake.exe \
      -G"Ninja" \
      -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
      "${_KDE_INSTALL_DIRS[@]}" \
      -DBUILD_TESTING=OFF \
      "${_extra_config[@]}" \
      -S "${_realname}-${pkgver}" \
      -B "build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/cmake.exe --build "build-${MSYSTEM}"
}

package() {
  DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install "build-${MSYSTEM}"

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
